//
//  ViewController.m
//  TestDemo
//
//  Created by 张润东 on 2021/3/4.
//

#import "AViewController.h"
#import "BViewController.h"
@interface AViewController ()
@end

@implementation AViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title= @"A页面";
    UIButton *btn = [UIButton new];
    btn.frame = CGRectMake(0, 0, 100, 100);
    btn.backgroundColor =[UIColor blackColor];
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(pushNew) forControlEvents:UIControlEventTouchUpInside];
}

-(void)pushNew{
    if(self.navigationController.viewControllers.count==2){
        BViewController*vc = [BViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }else{
        AViewController*vc = [AViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}



@end
